/**
 * @author koga
 */

var objMap = null;
var divMap = null;
var objMarker = null;
var zoom = 8;

function onLoad() {
 	if (GBrowserIsCompatible())
	{
		divMap = document.getElementById("map");
		objMap = new GMap2(divMap);
		
		objMap.addControl(new GLargeMapControl());
		objMap.addControl(new GOverviewMapControl());
		objMap.addControl(new GMapTypeControl());
		objMap.addControl(new GScaleControl());
		objMap.setCenter(new GLatLng(34.65,135),zoom);
		
		objMap.enableContinuousZoom();
		
		GEvent.addListener(objMap, "click", function(overlay,point)
		{
			if (point)
			{
				showInfo(point);
			}
		})
	}
}

function showInfo(point) {
	objMap.clearOverlays();
	objMap.panTo(new GLatLng(point.y, point.x));
	
	objMarker = new GMarker(point);
	objMap.addOverlay(objMarker);
	var msg = "緯度:" + point.y + "<br>経度:" + point.x;
	objMarker.openInfoWindowHtml(msg);
	
	document.getElementById("spot_long").value = point.x;
	document.getElementById("spot_lat").value = point.y;
}
